package com.ego.product.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ego.product.dao.SpuImageDao;
import com.ego.product.po.SpuImage;
import com.ego.product.service.SpuImageService;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: ego
 * @description spu图片对应实现类
 * @author KamTang
 * @date 2022-11-13 12:56:14
 */
@Service("spuImagesService")
public class SpuImageServiceImpl extends ServiceImpl<SpuImageDao, SpuImage> implements SpuImageService {
    @Override
    public void saves(Long id, List<String> images) {
        if (!CollectionUtils.isEmpty(images)) {
            List<SpuImage> spuImages = images.stream()
                    .map(img -> new SpuImage().setSpuId(id).setImgUrl(img)).collect(Collectors.toList());
            this.saveBatch(spuImages);
        }
    }
}
